{extend name="../../admin/view/main"}
{block name="content"}
<div class="layui-tab layui-tab-card think-bg-white">
    <div class="layui-tab-content">
        {include file='control/storehouse_data/index_search'}
        <table class="layui-table margin-top-10" lay-skin="line">
            {notempty name='list'}
            <thead>
            <tr>
                <th class='list-table-check-td think-checkbox'>
                    <label><input data-auto-none data-check-target='.list-check-box' type='checkbox'></label>
                </th>
                <th class='text-left nowrap'>配件编号</th>
                <th class='text-left nowrap'>配件名称</th>
                <th class='text-left nowrap'>型号/规格</th>
                <th class='text-left nowrap'>单位</th>
                <th class='text-left nowrap'>单价</th>
                <th class='text-left nowrap'>数量</th>
                <th class='text-left nowrap'>小计</th>
                <th class='text-left nowrap'></th>
            </tr>
            </thead>
            {/notempty}
            <tbody>
            {foreach $list as $key=>$vo}
            <tr>
                <td class='list-table-check-td think-checkbox'>
                    <label><input class="list-check-box" type='checkbox' value='{$vo.material_code}'></label>
                </td>
                <td class='nowrap'>
                    <div class="inline-block text-top sub-span-blue">
                        <div>编号：<span>{$vo.material_code|default='--'}</span></div>
                    </div>
                </td>
                <td class='nowrap'>
                    <div class="inline-block text-top sub-span-blue">
                        <div>名称：<span>{$vo.material_name|default='--'}</span></div>
                    </div>
                </td>
                <td class='nowrap'>
                    <div class="inline-block text-top sub-span-blue">
                        <div>规格：<span>{$vo.material_model|default='--'}</span></div>
                    </div>
                </td>
                <td class='nowrap'>
                    <div class="inline-block text-top sub-span-blue">
                        <div>单位：<span>{$vo.material_unit|default='--'}</span></div>
                    </div>
                </td>
                <td class='nowrap'>
                    <div class="inline-block text-top sub-span-blue">
                        <div>单价：<span>{$vo.material_price|default='--'}</span></div>
                    </div>
                </td>
                <td class='nowrap'>
                    <div class="inline-block text-top sub-span-blue">
                        <div>数量：<span>{$vo.material_num|default='--'}</span></div>
                    </div>
                </td>
                <td class='nowrap'>
                    <div class="inline-block text-top sub-span-blue">
                        <div>小计：<span>{$vo.material_price * $vo.material_num}</span></div>
                    </div>
                </td>
                <td class='nowrap'>

                    <a class="layui-btn layui-btn-xs layui-btn-danger" onclick="refusalCause('{$vo.id}');">退 还</a>
                </td>

            </tr>
            {/foreach}
            </tbody>
        </table>
        {empty name='list'}<span class="notdata">没有记录哦</span>{else}{$pagehtml|raw|default=''}{/empty}
    </div>
    <script>
        form.render()
        function refusalCause(ids) {
            var remarkReason = "";
            layer.prompt({
                formType: 0,
                value: '',
                title: '请输入退还数量',
                btn: ['确定','取消'], //按钮，
                btnAlign: 'c'
            }, function(value,index){
                remarkReason = value;
                layer.close(index);
                $.ajax({
                    type: 'POST',
                    url: "{:url('give_back_num')}",
                    data: {
                        id: ids,
                        num: remarkReason
                    },
                    dataType: "json",
                    success: function (data) {
                        console.log(data)
                        if(data.code==1){
                            layer.msg(data.info, {icon: 1},function () {
                                console.log(index)
                                layer.msg(data.info,{time: 3000, icon:1})
                                parent.location.reload();
                            });
                        }else{
                            layer.msg(data.info,{time: 3000, icon:2})
                        }
                    }
                });
            },function (value,index) {

            });
        }
    </script>
</div>
{/block}